#include <stdio.h>
#include <stdlib.h>

#define true 1
#define false 0
typedef unsigned char bool;
#define MaxSize 10
typedef struct{
    int data[MaxSize];
    int length;
}SqList;

void InitList(SqList *L){
    for(int i=0; i<MaxSize; i++){
        L->data[i] = 0; //将所有数据元素设置为默认值
    }
    L->length = 0;      //顺序表初始长度为0
}

//在顺序表L中查找第一个元素值等于e的元素，并返回其位序
int LocateElem(SqList *L,int e){
    for(int i=0;i<L->length;i++)
        if(L->data[i]==e){
            return i+1;//数组下标为i的元素值等于e，返回其位序i+1
        }
    return 0;//退出循环，说明查找失败
}

int main(){
    SqList L;
    int e = -1;
    InitList(&L);

    printf("insert some values:111 data[0]~data[5]\n");
    for (int i = 0;i<=5;i++){
        L.data[i] = i*111;
    }
    L.length = 6;

    for (int i = 0;i<=L.length-1;i++){
        printf("data[%d] = %d\n",i,L.data[i]);
    }

    printf("value = %d =>位序 = %d",333,LocateElem(&L, 333));

    return 0;
}
